package com.lai.shop.strategy.context;

import com.lai.shop.entity.UserEntity;
import com.lai.shop.enums.LoginTypeEnum;
import com.lai.shop.strategy.SocialLoginStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class SocialLoginStrategyContext {

    @Autowired
    private Map<String, SocialLoginStrategy> socialLoginStrategyMap;



    public UserEntity executeLoginStrategy(String data, LoginTypeEnum loginTypeEnum) {
        UserEntity user = socialLoginStrategyMap.get(loginTypeEnum.getStrategy()).login(data);
        return user;
    }

}
